﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using Unity.Collections;

[System.Serializable]
public class ShadowSettings
{
    [Min(0f)]
    public float maxDistance = 100f;

    public enum TextureSize
    {
        _256 = 256, _512 = 512, _1024 = 104,
        _2048 = 2048, _4096 = 4096, _8192
    }

    public enum DepthSize
    {
        _16 = 16, _32 = 32
    }

    public TextureSize ShadowTextureSize = TextureSize._512;
    public DepthSize ShadowTextureDepthSize = DepthSize._16;

    private float _shadowBias;
    public float ShadowBias
    {
        get
        {
            return _shadowBias;
        }
    }

    private float _shadowStrength;
    public float ShadowStrength
    {
        get
        {
            return _shadowStrength;
        }
    }

    private NativeArray<VisibleLight> _visibleLights;
    private Vector4 _shadowMapSize;
    public Vector4 ShadowMapSize
    {
        get
        {
            return _shadowMapSize;
        }
    }


    private float _invShadowMapSize;
    public float InvShadowMapSize
    {
        get 
        {
            return _invShadowMapSize;
        }
    }




    public void Setup(NativeArray<VisibleLight> vLights)
    {
        _visibleLights = vLights;
        _invShadowMapSize = 1.0f / (int)ShadowTextureSize;
        _shadowMapSize = new Vector4(_invShadowMapSize, _invShadowMapSize, (int)ShadowTextureSize, (int)ShadowTextureSize);

    }

    public float GetShadowBias(int i)
    {
        if(i >= _visibleLights.Length)
        {
            return -1;
        }

        return _visibleLights[i].light.shadowBias;
    }

    public float GetShadowStrength(int i)
    {
        if (i >= _visibleLights.Length)
        {
            return -1;
        }
        return _visibleLights[i].light.shadowStrength;
    }


}
